home *** CD-ROM | disk | FTP | other *** search
- Path: news.nrlssc.navy.mil!proteus!jacobs
- From: jacobs@proteus (Gregg A. Jacobs (X4720))
- Newsgroups: comp.lang.c++
- Subject: C++ calling Fortran
- Date: 12 Mar 1996 15:58:51 GMT
- Organization: Naval Research Laboratory, Stennis Space Center
- Message-ID: <4i46vr$njn@filet.nrlssc.navy.mil>
- NNTP-Posting-Host: proteus.nrlssc.navy.mil
- X-Newsreader: TIN [version 1.2 PL2]
-
- I want a C++ program to call a subroutine written in fortran.
-
- If the fortran subroutine is:
-
- subroutine foo(a)
- real a
- return
- end
-
- Then f77 generates an object file with a subroutine name of:
-
- _foo_
-
- A C (or C++) routine calling this would be:
-
- void foo_(float *a);
-
- main() {
-
- float a;
- foo_(&a);
- }
-
- The gcc compiler then generates an object file which looks for
- the name:
- _foo_
- This is fine, and the C program calls the fortran subroutine
-
- However, g++ generates an object file which looks for the name:
- _foo___FPf
- The linker can not find this, so the C++ code will not call
- the fortran subroutine.
-
-
- --
- ========================================
- === Gregg Jacobs ===
- === Naval Research Lab ===
- === Stennis Space Center, MS 39529 ===
- === ===
- === Building 1007 room 48 ===
- ========================================
- === jacobs@nrlssc.navy.mil ===
- === phone: (601) 688-4720 ===
- === FAX: (601) 688-4759 ===
- ========================================
- === "The reason for time is so ===
- === that everything does not ===
- === happen at once." -- BB ===
- ========================================
-